|
|
|
|
|
|
|
Figure 2.8
An ellipse defined by the Ellipse API function. |
|
|
|
|
|
|
|
|
The Chord function draws an arc of an ellipse much as the Arc function does. It then draws a line connecting the endpoints of the arc. The chord is filled using the current FillStyle and FillColor. Figure 2.10 shows how the Chord function's parameters determine the shape of the chord. |
|
|
|
|
|
|
|
|
The Pie function is similar to the Chord function, except it draws lines from the center of the ellipse to the endpoints of the arc rather than connecting the endpoints. It fills the resulting pie slice using the current FillStyle and FillColor. Figure 2.11 shows how the Pie function draws a pie slice. |
|
|
|
|
|
|
|
|
Example program Curves, shown in Figure 2.12, demonstrates these four functions. Whenever you resize the form, and when the form is initially created, the program draws an example ellipse, arc, chord, and pie slice. |
|
|
|
|
|
|
|
|
Visual Basic provides various properties, like DrawMode and FillStyle, that determine the graphic characteristics of the items you draw. You can set DrawStyle to vbDot, for example, to make Visual Basic draw with dotted lines. |
|
|
|
|
|
|
|
|
In a similar manner, the Windows API uses pens and brushes to specify how lines should be drawn and shapes filled. To use a pen, you first create it using the CreatePen or CreatePenIndirect function. Next, you use the SelectObject function to make future graphic |
|
|
|
|
|
|
|
|
Figure 2.9
An arc drawn by the Arc API function. |
|
|
|
|
|